/*
 * @Author: 陈俊升 761723995@qq.com
 * @Date: 2023-11-01 17:58:22
 * @LastEditors: 陈俊升 761723995@qq.com
 * @LastEditTime: 2024-01-29 15:39:53
 * @FilePath: /hr_new_vue3/src/apis/management/personnel/changeManagement/transactionManagement/index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/* 人员 人事异动管理api */

import { ajaxService } from '@/utils/request';
import * as typeObj from './type';

const env = import.meta.env;
// const baseURL1 = env.VITE_API_BASE_URL;
const baseURL1 = env.VITE_DEV_BASE_URL;
const baseURL = env.VITE_DEV_BASE_URL;

/**
 * 确认发起人事异动（同时修改控件内容）
 */
export function ConfirmSendTransaction(data: any) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/personnel/set',
    method: 'put',
    data,
    baseURL
  });
}

/**
 * 发起人事异动（还不改控件的内容，只有审批完确认才改控件内容）
 */
export function SendTransaction(data: any) {
  return ajaxService(
    {
      url: '/hr/personnel_matters/roster/movement/list',
      method: 'post',
      data,
      baseURL,
      isLoading: true
    },
    {
      mode: 'success',
      message: '提交成功！'
    }
  );
}

/**
 * 编辑人事异动
 */
export function PutTransaction(data: any) {
  return ajaxService(
    {
      url: '/hr/personnel_matters/roster/movement/list',
      method: 'put',
      data,
      baseURL,
      isLoading: true,
      loadingTip: '提交中'
    },
    {
      mode: 'success',
      message: '保存成功！'
    }
  );
}

/**
 * 撤销人事异动
 */
export function DelTransaction(data: { ids: [] }) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/movement/list/detail/id',
    method: 'delete',
    data,
    baseURL
  });
}

/**
 * 获取最新人事异动详情
 */
export function GetTransactionLatestDetail(params: { id: number }) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/movement/list',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 获取单个员工人事异动记录
 */
export function GetTransactionDetailList(params: { id: number }) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/movement/list/id',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 获取异动记录列表
 */
export function GetTransactionRecordList(params: any) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/movement/list/detail',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 获取人事异动详情
 */
export function GetTransactionDetail(params: { id: number }) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/movement/list/detail/id',
    method: 'get',
    params,
    baseURL
  });
}
